package com.homework.homework2;

import java.util.ArrayList;
import java.util.Iterator;

public class test01 {
    public static void main(String[] args) {
        ArrayList<Person> person = new ArrayList<>();
        person.add(0,new Person("张三",20,1.80));
        person.add(1,new Person("李四",20,1.76));
        person.add(2,new Person("张1",20,1.75));
        person.add(3,new Person("张2",20,1.74));
        person.add(4,new Person("张3",20,1.73));
        Iterator<Person> iterator = person.iterator();
        double tallMax=iterator.next().getHeight();
        double shortMin=iterator.next().getHeight();
        while (iterator.hasNext()){
            double height = iterator.next().getHeight();
            if(height>tallMax){
                tallMax=height;
            }
            if(shortMin>height){
                shortMin=height;
            }
        }
        System.out.println("最高的是张三"+"身高是："+tallMax);
        System.out.println("最矮的是李四"+"身高是："+shortMin);
    }
}
